﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<JLL.China.Web.Areas.Portal.Models.BannerModel>" %>
<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .label
    {
        margin-left: 50px;
    }
</style>
<% using (Html.BeginForm("Create", "HomeBanner", FormMethod.Post, new { id = "formID", enctype = "multipart/form-data", @class = "validateform" }))
   { %>
<%=Html.HiddenFor(x => x.Banner.Banner_ID) %>

<table align="left" cellpadding="10" cellspacing="10" class="style1" 
    style="padding: 5px">
    <tr>
        <td width="15%">
             <label>
                    Title (English):
                </label></td>
        <td width="20%" style="padding: 5px; margin: 5px">
            <%= Html.TextBoxFor(m => m.Banner.Title,
                                           new
                                               {
                                                   name = "title",
                                                   id = "title",
                                                   @class = "validate[required] inp-form",
                                                   style = "width: 100%"
                                               }) %></td>
        <td width="20%">
            <label style="margin-left: 50px;">Title (Local)</label></td>
        <td>
             <%= Html.TextBoxFor(m => m.Banner_Local.Title, new { name = "title_local", id = "title_local", @class = "validate[required] inp-form", style = "width: 100%" })%>
   </td>
        <td width="%">
            &nbsp;</td>
    </tr>
    <tr>
        <td width="15%">
            <label>Show Banner Details:</label></td>
        <td width="20%" style="padding: 5px; margin: 5px">
           <div class="select_holder">
                    <%=Html.DropDownListFor(m => m.Banner.Status, new List<SelectListItem>
                                                             {
                                                                new SelectListItem{Selected = true, Text="Show", Value = "true" }, 
                                                                new SelectListItem{Selected = false, Text="Hide", Value = "false" },
                                                             }, new { id = "banner_status", name = "banner_status", @class = "chzn-nosearch chz" })%></div></td>
        <td width="20%">
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td width="%">
            &nbsp;</td>
    </tr>
    <tr>
        <td width="15%">
            <label>Link Banner to:</label></td>
        <td width="20%" style="padding: 5px; margin: 5px">
             <%= Html.TextBoxFor(m => m.Banner.Link, new { name = "link", id = "link", @class = "validate[required] inp-form", style = "width: 100%" })%></td>
        <td width="20%">
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td width="%">
            &nbsp;</td>
    </tr>
    <tr>
        <td width="15%">
            <label>Select Image:</label></td>
        <td width="20%" style="padding: 5px; margin: 5px">
            <script>
                                    function checkFileExtension(elem) {
                                        var filePath = elem.value;


                                        if (filePath.indexOf('.') == -1)
                                            return false;


                                        var validExtensions = new Array();
                                        var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();


                                        validExtensions[0] = 'jpg';
                                        validExtensions[1] = 'jpeg';
                                        validExtensions[2] = 'bmp';
                                        validExtensions[3] = 'png';
                                        validExtensions[4] = 'gif';



                                        for (var i = 0; i < validExtensions.length; i++) {
                                            if (ext == validExtensions[i])
                                                return true;
                                        }


                                        alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
                                        $('#inputfile').empty();
                                        $('#inputfile').html('<input type="file" onchange="checkFileExtension(this);" name="file" id="file" />');
                                        return false;
                                    }
</script>
               
           <div id="inputfile">  <input type="file" name="file" id="file" onchange="checkFileExtension(this);" /></div>
        </td>
        <td width="20%">
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td width="%">
            &nbsp;</td>
    </tr>
    <tr>
        <td width="15%">
            <label>
                    Description (English):</label></td>
        <td width="20%" style="padding: 5px; margin: 5px">
             <%--<input id="content_validate" class="validate[required]" style="visibility: hidden;
                    height: 0; width: 0" />--%>
                <%= Html.TextAreaFor(m => m.Banner.Content, new { id = "contentID", name = "contentID", cols = "5", rows = "2", @class="validate[required]", style = "width: 100%" })%>
           </td>
        <td width="20%">
            <label style="margin-left: 50px;">
                    Description (Local):</label></td>
        <td>
            <%-- <input id="content_local_validate" class="validate[required]" style="visibility: hidden;
                    height: 0; width: 0" />--%>
                <%= Html.TextAreaFor(m => m.Banner_Local.Content, new { id = "content_local", name = "content_local", cols = "5", rows = "2",@class="validate[required]", style = "width: 100%" })%>
            </td>
        <td width="%">
            &nbsp;</td>
    </tr>
    <tr>
        <td width="15%">
            &nbsp;</td>
        <td width="20%">
            &nbsp;</td>
        <td width="20%">
            &nbsp;</td>
        <td align="right">
            &nbsp;</td>
        <td align="right" width="%" style="padding: 10px; margin: 10px">
            <input type="submit" value="Submit"  onclick="checkForm()" class="buttons" style="margin-right:8px;float:left" />
 <input type="button" value="Cancel" class="buttons" style="margin-right:8px;float:left;cursor:pointer" onclick="window.location.href='<%=Url.Content("~/")%>Portal/HomeBanner/'"   />			</td>
    </tr>
    <tr>
        <td width="15%">
            &nbsp;</td>
        <td width="20%">
            &nbsp;</td>
        <td width="20%">
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td width="%">
            &nbsp;</td>
    </tr>
</table>


<%} %><!-- end id-form  -->